package com.imge;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.io.File;
import java.io.IOException;


import javax.imageio.ImageIO;

public class imageUtil {
    public static void pgm2png(String src, String dest) throws IOException {

        BufferedImage image = ImageIO.read(new File(src));
        Raster source = image.getRaster();
        int width = image.getWidth();
        int height = image.getHeight();

        // 创建BufferedImage对象
        // BufferedImage image2 = new BufferedImage(width,
        // height,BufferedImage.TYPE_BYTE_BINARY);//黑色
        BufferedImage image2 = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);// 灰色
        // BufferedImage image2 = new BufferedImage(width, height,
        // BufferedImage.TYPE_BYTE_INDEXED);//黄色
        image2.setData(source);
        // 保存文件
        ImageIO.write(image2, "png", new File(dest));
    }

    public static void main(String[] args) {
//        pgm2png("")
//        final boolean matches = "你好ss".matches("^[^\u4e00-\u9fa5]*$");
//        System.out.println(matches);
    }
}
